//
//  ViewController.m
//  CALayerTest
//
//  Created by Vincent on 2017/3/25.
//  Copyright © 2017年 Vincent. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property(nonatomic,strong)CALayer *layer;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.layer = [CALayer layer];
    self.layer.bounds = CGRectMake(0, 0, 100, 100);
    self.layer.position = CGPointMake(50, 50);
    self.layer.backgroundColor = [UIColor redColor].CGColor;
    [self.view.layer addSublayer:self.layer];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    CGPoint anchpoint = self.layer.anchorPoint;
    anchpoint.x += 0.5;
    
    if(anchpoint.x>=1.5){
        anchpoint.x = 0;
    }
    self.layer.anchorPoint = anchpoint;
    
    /**
     *layer 的position 是图层的中心点位置，anchorPoint永远和position重合的点;
     *
     */

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
